package de.nak.fireDepartment.actionForms;

import java.util.Collection;

import org.apache.struts.upload.FormFile;
import org.apache.struts.validator.ValidatorForm;

import de.nak.fireDepartment.model.Car;
import de.nak.fireDepartment.model.Department;

/**
 * Action form the handling with the departments
 * 
 * @author Sven Redelin
 */
@SuppressWarnings("serial")
public class DepartmentForm extends ValidatorForm {
	/** Attribute containing the selected key. */
	private Long selectedKey;
	/** The list containing all departments. */
	private Collection<Department> departments;
	/** The current department. */
	private Department department;
	/** The linked carIds */
	private Long[] selectedCarIds;
	/** The linked carNames */
	private Collection<String> selectedCarNames;
	/** The Image-File for the Department */
	private FormFile aDepartmentImageFile;
	/** The cars can be linked */
	private Collection<Car> cars;
	/** A Error Code to display */
	private String errorCode;
	
	/**
	 * Returns the selected department id.
	 * @return a Long value.
	 */
	public Long getSelectedKey() {
		return selectedKey;
	}

	/**
	 * Sets the selected department id.
	 * @param Long value to set.
	 */
	public void setSelectedKey(Long selectedKey) {
		this.selectedKey = selectedKey;
	}

	/**
	 * Returns the list of departments.
	 * @return the department list.
	 */
	public Collection<Department> getDepartments() {
		return departments;
	}
	
	/**
	 * Sets the list of departments.
	 * @param list of departments to set.
	 */
	public void setDepartments(Collection<Department> departments) {
		this.departments = departments;
	}

	/**
	 * Returns the current department.
	 * @return the department.
	 */
	public Department getDepartment() {
		return department;
	}

	/**
	 * Sets the current department.
	 * @param the department to set.
	 */
	public void setDepartment(Department department) {
		this.department = department;
	}

	/**
	 * Gets the selectedCarIDs
	 * @return array of Long values
	 */
	public Long[] getSelectedCarIds() {
		return selectedCarIds;
	}

	/**
	 * Sets the selectedCarIDs
	 * @param array of Long values
	 */
	public void setSelectedCarIds(Long[] selectedCarIds) {
		this.selectedCarIds = selectedCarIds;
	}
	
	/**
	 * Get the selectedCarNames
	 * @return list of selectedCarNames
	 */
	public Collection<String> getSelectedCarNames() {
		return selectedCarNames;
	}

	/**
	 * Sets the selectedCarNames
	 * @param list of selectedCarNames to set
	 */
	public void setSelectedCarNames(Collection<String> selectedCarNames) {
		this.selectedCarNames = selectedCarNames;
	}

	/**
	 * Gets the Cars
	 * @return list of cars
	 */
	public Collection<Car> getCars() {
		return cars;
	}

	/**
	 * Sets the cars
	 * @param list of cars
	 */
	public void setCars(Collection<Car> cars) {
		this.cars = cars;
	}

	/**
	 * Gets the departmentImage File
	 * @return department image as formfile
	 */
	public FormFile getaDepartmentImageFile() {
		return aDepartmentImageFile;
	}

	/**
	 * Sets the departmentImage File
	 * @param formFile to set
	 */
	public void setaDepartmentImageFile(FormFile aDepartmentImageFile) {
		this.aDepartmentImageFile = aDepartmentImageFile;
	}

	/**
	 * Gets the errorCode
	 * @return the errorCode as string
	 */
	public String getErrorCode() {
		if (errorCode == null || errorCode.equals("")){
			errorCode = "text.error.empty";
		}	
		return errorCode;
	}

	/**
	 * Sets the errorCode
	 * @param String to set
	 */
	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}
	
	
	
}
